/*
 * Lenovo Group
 * Copyright (c) 2015-2016 All Rights Reserved.
 * 
 * Project Name:assign-tracer
 * Create Time: 2016年2月18日 上午10:40:34
 */
package com.lenovo.lmrp.server.assigntracer.util.pusher;

import javax.inject.Inject;
import javax.inject.Named;

import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.Scopes;

/**
 * 
 * @author songyz
 * @version $Id: APushFactory.java, v 0.1 2016年2月18日 上午10:40:34 songyz Exp $
 */
public abstract class APushFactory {

    private static APushFactory factory;

    public static APushFactory getPushFactory() {
        return factory;
    }

    @Inject
    public static void setPushFactory(APushFactory factory) {
        APushFactory.factory = factory;
    }

    public abstract SMSSender getSMSSender();

    public abstract GeTuiSender getGeTuiSender();

    public abstract EmailSender getEmailSender();

    @Named("default")
    public static class PushFactoryImpl extends APushFactory {

        @Inject
        private SMSSender smsSender;
        private GeTuiSender geTuiSender;
        private EmailSender emailSender;

        @Override
        public SMSSender getSMSSender() {
            return smsSender;
        }

        @Override
        public GeTuiSender getGeTuiSender() {
            return geTuiSender;
        }

        @Override
        public EmailSender getEmailSender() {
            return emailSender;
        }
    }

    public static class PushModule implements Module {

        @Override
        public void configure(Binder binder) {
            binder.bind(SMSSender.class).in(Scopes.SINGLETON);
            binder.bind(GeTuiSender.class).in(Scopes.SINGLETON);
            binder.bind(EmailSender.class).in(Scopes.SINGLETON);

            binder.bind(APushFactory.class).to(PushFactoryImpl.class).in(Scopes.SINGLETON);
            binder.requestStaticInjection(APushFactory.class);
        }

    }
}
